using System.Collections.Generic;
using com.tc.util;
using  com.tc.zigbee.zcl;
using  com.tc.zigbee.entity;
using  com.tc.zigbee.zcl.command;
namespace com.tc.zigbee.mt.income
{
    //1  1  1  2  1  2  1 
    //Length = 0x06-4E  Cmd0 = 0x45  Cmd1 = 0x84  SrcAddr  Status  NwkAddr  Len 
    //1  2  2  1 
    //Endpoint  ProfileId  DeviceId  DeviceVersion 
    //1  0-32  1  0-32 
    //NumInClusters  InClusterList  NumOutClusters  OutClusterList 
    //
    //
    public class SimpleDescriptorResponse : IncomeMessage
    {
        public SimpleDescriptorResponse(byte[] data)
        {

            byte[] na = new byte[2];
            na[0] = data[0];
            na[1] = data[1];
            srcAddress = DataUtil.shortValue(na);
            status = data[2];
            na[0] = data[3];
            na[1] = data[4];


            nwkAddress = DataUtil.shortValue(na);
            byte len = data[5];
            endpoint.setEndpointId(data[6]);
            na[0] = data[7];
            na[1] = data[8];
            endpoint.setProfileId(DataUtil.shortValue(na));
            na[0] = data[9];
            na[1] = data[10];
            endpoint.setDeviceId(DataUtil.shortValue(na));

            endpoint.setDeviceVersion(data[11]);
            endpoint.setNumInClusters(data[12]);
            for (int i = 0; i < endpoint.getNumInClusters(); i++)
            {
                na[0] = data[13 + i * 2];
                na[1] = data[13 + i * 2 + 1];
                endpoint.getInClusters().Add(DataUtil.shortValue(na));

            }
            int start = 13 + endpoint.getNumInClusters() * 2;
            endpoint.setNumOutClusters(data[start++]);

            for (int i = 0; i < endpoint.getNumOutClusters(); i++)
            {
                na[0] = data[start + i * 2];
                na[1] = data[start + i * 2 + 1];
                endpoint.getOutClusters().Add(DataUtil.shortValue(na));

            }
        }
        byte status;
        short srcAddress;
        short nwkAddress;
        byte len;
        Endpoint endpoint = new Endpoint(null, (byte)0, null);

        public byte getStatus()
        {
            return status;
        }
        public short getNwkAddress()
        {
            return nwkAddress;
        }
        public Endpoint getEndpoint()
        {
            return endpoint;
        }


    }
}